#include "window.h"
#include <QTextEdit>
#include <QTextCursor>

window::window(QWidget *parent, Qt::WFlags flags)
	: QMainWindow(parent, flags)
{
	ui = new Ui::windowClass;
	ui->setupUi(this);
	connect(ui->text ,SIGNAL(cursorPositionChanged ()),this,SLOT(hightlighttext()));
}

window::~window()
{

}
 
void window::hightlighttext()
{
/*	int begin =0;
	int end = 1;
	QTextCharFormat block;
	QTextCharFormat predicate;
	QTextCharFormat type;
	QTextCharFormat function;
	QTextCharFormat variable;
	QTextCharFormat value;
	block.setForeground(Qt::red);
	predicate.setForeground(Qt::green);
	type.setForeground(Qt::cyan);
	function.setForeground(Qt::blue);
	value.setForeground(Qt::white);
	value.setBackground(Qt::magenta);
	variable.setForeground(Qt::magenta);
	QTextDocument* text = ui->text->document();
	QTextCursor cursor(text);
	yy_scan_string(	ui->text->document()->toPlainText().toAscii().data());
	int current=0;
	cursor.setPosition(begin, QTextCursor::MoveAnchor);
	cursor.setPosition(begin, QTextCursor::KeepAnchor);
	do
	{
		QTextCharFormat	  temp;

		current = yylex();
		switch(current)
		{
		case 1:
			temp=predicate;
			break;
		case 2:
			temp=variable;
			break;
		case 3:
			temp=type;
			break;
		case 4:
			temp=function;
			break;
		case 6:
			temp=block;
			break;
		case 8:
			temp=value;
			break;
		default:
			temp.setForeground(Qt::black);
		}
		cursor=	text->find(QString(yytext),cursor);
		cursor.setCharFormat(temp);
	} while(current !=0);*/
}